/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.inv.controller;

import java.util.Map;
import java.util.List;
import com.dian.common.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.inv.entity.GoodsAccountEntity;
import com.dian.modules.inv.service.GoodsAccountService;
import com.dian.modules.inv.poi.vo.GoodsAccountExportVO;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;


/**
 * 月结报表
 *
 * @author xiaolai
 * @email xiaolai@9dyun.cn
 * @date 2019-06-27 11:48:04
 */
@RestController
@Api("月结报表接口")
@RequestMapping("inv/goodsAccount")
public class GoodsAccountController extends AbstractController{
    @Autowired
    private GoodsAccountService goodsAccountService;

    /**
     * 月结报表列表
     */
    @SysLog("月结报表列表")
    @GetMapping("/list")
    @ApiOperation("月结报表列表")
    @RequiresPermissions("inv:goodsAccount:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = goodsAccountService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 月结报表信息
     */
    @SysLog("月结报表信息")
    @ApiOperation("月结报表信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("inv:goodsAccount:info")
    public R info(@PathVariable("id") Long id){

        GoodsAccountEntity goodsAccount = goodsAccountService.getInfo(id);

        return R.ok().put(goodsAccount);
    }

    /**
     * 月结报表保存
     */
    @SysLog("月结报表保存")
    @ApiOperation("月结报表保存")
    @PostMapping("/save")
    @RequiresPermissions("inv:GoodsAccount:save")
    public R save(@RequestBody GoodsAccountEntity goodsAccount){

		goodsAccountService.saveInfo(goodsAccount);

        return R.ok();
    }

    /**
     * 月结报表修改
     */
    @SysLog("月结报表修改")
    @ApiOperation("月结报表修改")
    @PostMapping("/update")
    @RequiresPermissions("inv:goodsAccount:update")
    public R update(@RequestBody GoodsAccountEntity goodsAccount){

		goodsAccountService.updateInfo(goodsAccount);

        return R.ok();
    }

    /**
     * 月结报表删除
     */
    @SysLog("月结报表删除")
    @ApiOperation("月结报表删除")
    @GetMapping("/delete")
    @RequiresPermissions("inv:goodsAccount:delete")
    public R delete(@RequestBody Long[] ids){

		goodsAccountService.deleteInfo(ids);

        return R.ok();
    }


    /**
     * 月结报表审核
     */
    @SysLog("月结报表审核")
    @ApiOperation("月结报表审核")
    @GetMapping("/check/{id}")
    @RequiresPermissions("inv:goodsAccount:check")
    public R check(@PathVariable("id") Long id){

        goodsAccountService.checkInfo(id);

        return R.ok();
    }


    /**
     * 月结报表导出
     */
    @SysLog("月结报表导出")
    @ApiOperation("月结报表导出")
    @GetMapping("/export")
    @RequiresPermissions("inv:goodsAccount:export")
    public void export(@RequestParam Map<String, Object> params){

        List<GoodsAccountExportVO> list = goodsAccountService.exportList(params);

        exportExcel(list,"月结报表","月结报表",GoodsAccountExportVO.class,"月结报表.xls");
    }



    /**
     * 仓库月结查询
     */
    @SysLog("仓库月结查询")
    @ApiOperation("仓库月结查询")
    @GetMapping("/warehouseList")
    @RequiresPermissions("inv:goodsAccount:list")
    public R warehouseList(@RequestParam Map<String, Object> params){

        PageUtils page = goodsAccountService.warehouseList(params);

        return R.ok().put("page", page);

    }

}
